package com.tarena.csmall.test.spring.condition;

import com.tarena.csmall.test.spring.bean.Bean05;
import com.tarena.csmall.test.spring.bean.Bean06;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
//当前容器要有一个属性
//前缀csmall 名称是password csmall.password
//并且他的值必须是123456才满足条件
//matchIfMissing 定义的是,如果这个属性不存在,那么是否判断最终结果是满足条件
//和havingValue一般不在一起使用
@ConditionalOnProperty(
    prefix = "csmall",
    value="password",
    havingValue = "123",
    matchIfMissing = false)
public class ConditionConfig02 {
    public ConditionConfig02() {
        System.out.println("容器加载了ConditionConfig02对象");
    }
    @Bean
    public Bean06 bean06(){
        return new Bean06();
    }
}
